(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseHousekeepingServ: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseHousekeepingServInfo: {
                housekeepingServs: [],
                _currentHousekeepingServName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseHousekeepingServ', 'openChooseHousekeepingServModel', function (_param) {
                $('#chooseHousekeepingServModel').modal('show');
                $that._refreshChooseHousekeepingServInfo();
                $that._loadAllHousekeepingServInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllHousekeepingServInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        communityId: vc.getCurrentCommunity().communityId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('housekeepingServ.listHousekeepingServs',
                    param,
                    function (json) {
                        var _housekeepingServInfo = JSON.parse(json);
                        $that.chooseHousekeepingServInfo.housekeepingServs = _housekeepingServInfo.housekeepingServs;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseHousekeepingServ: function (_housekeepingServ) {
                if (_housekeepingServ.hasOwnProperty('name')) {
                    _housekeepingServ.housekeepingServName = _housekeepingServ.name;
                }
                vc.emit($props.emitChooseHousekeepingServ, 'chooseHousekeepingServ', _housekeepingServ);
                vc.emit($props.emitLoadData, 'listHousekeepingServData', {
                    housekeepingServId: _housekeepingServ.housekeepingServId
                });
                $('#chooseHousekeepingServModel').modal('hide');
            },
            queryHousekeepingServs: function () {
                $that._loadAllHousekeepingServInfo(1, 10, $that.chooseHousekeepingServInfo._currentHousekeepingServName);
            },
            _refreshChooseHousekeepingServInfo: function () {
                $that.chooseHousekeepingServInfo._currentHousekeepingServName = "";
            }
        }

    });
})(window.vc);
